<?php

namespace app\index\controller;

use app\common\lib\Util;
use app\common\lib\redis\Predis;
use app\common\lib\Redis;

class Send
{
    public function index()
    {
        $phoneNum = request()->get('phone_num',0,'intval');
        if(empty($phoneNum)){
            return Util::show(config('code.error'),'参数错误');
        }
        // 生成验证码
        $code = rand(1000,9999);
        $taskData = [
            'method' => 'sendSms',
            'data' => [
                'phone' => $phoneNum,
                'code' => $code,
            ],
        ];
        try{
            $_POST['http_server']->task($taskData);
        }catch(\Exception $e){
            return Util::show(config('code.error'),$e->getMessage());
        }
        return Util::show(config('code.success'),'ok');
    }
}
